package ${packageName}.module.${moduleName}.mybatis.mapper;

import com.alibaba.fastjson.JSON;
import ${packageName}.BaseTest;
import ${packageName}.frame.util.DateUtils;
import ${packageName}.module.comm.enums.DeleteFlagEnum;
import ${packageName}.module.comm.enums.StatusEnum;
import ${packageName}.module.${moduleName}.mybatis.mapper.${className}Mapper;
import ${packageName}.module.${moduleName}.po.${className}PO;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * ${tableDesc}信息业务逻辑和数据库单元测试类
 *
 * @author ${author}
 * @version 1.0
 * @filename Test${className}Mapper.java
 * @copyright www.unitd.cn
 * @date ${date}
 */
public class Test${className}Mapper extends BaseTest {

    @Autowired
    private ${className}Mapper ${className?uncap_first}Mapper;

    @Test
    public void testInsert() {
        ${className}PO ${className?uncap_first} = new ${className}PO();
        ${className?uncap_first}

        <#list model_column as model>
            <#if (model.changeColumnName?cap_first!='id' && model.changeColumnName?cap_first!='tmSmp')>
//                  .set${model.changeColumnName?cap_first}()
            </#if>
        </#list>
            .setCreateTime(DateUtils.getCurrDate(DateUtils.TIMESTAMP_PATTERN))
            .setUpdateTime(DateUtils.getCurrDate(DateUtils.TIMESTAMP_PATTERN));
        int result = ${className?uncap_first}Mapper.insert(${className?uncap_first});
        System.out.println("插入数据记录数：" + result);
    }

    @Test
    public void testSearch() {
        ${className}PO result = ${className?uncap_first}Mapper.selectById(1);
        System.out.println("根据主键查询：" + JSON.toJSONString(result));
        System.out.println("==================================");

        List<${className}PO> list = ${className?uncap_first}Mapper.selectList(new QueryWrapper<${className}PO>().eq("status", StatusEnum.ONE.getCode()));
        System.out.println("查询多条记录：" + JSON.toJSONString(list));
        System.out.println("==================================");

        ${className}PO ${className?uncap_first} = ${className?uncap_first}Mapper.selectOne(new QueryWrapper<${className}PO>().eq("status", StatusEnum.ONE.getCode()).eq("delete_flag", DeleteFlagEnum.NO.getCode()));
        System.out.println("查询单条记录：" + JSON.toJSONString(${className?uncap_first}));
    }
}